<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>动态改变购买数量</title>
<link href="css/detail.css" rel="stylesheet" />
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
</head>
<body>
<div class="prod-buychoose">
  <dl class="pProps" id="choosenum">
    <dt>购买数量： </dt>
    <dd id="choose-num"><a class="reduce" id="jian" onClick="reductBuynum()"></a>
    <input id="buycount" value="1" /> 
    <a class="add" id="jia" onClick="addBuynum()"></a>
    </dd>
  </dl>
</div>
<script type="text/javascript">
function addBuynum(){
  var s = $("#buycount").val();
  if(!numcheck(s)){
	  s=1;
  }
  s = Number(s);
  s = s+1;
  $("#buycount").val(s);
  return false;
}
function reductBuynum(){
  var s =$("#buycount").val();
  if(!numcheck(s)){
	$("#buycount").val(1);
	s=1;
  }
  s = Number(s);
  if(s == 1){
	return;
  } else {
	s = s-1;
  }
  $("#buycount").val(s);
  return false;
}
function numcheck(ss){ 
  var re = /^\+?[1-9][0-9]*$/;
  var stem = ss.indexOf(".");
  if(re.test(ss) && stem < 0) 
  { 
	return true;
  } 
  return false;
} 
</script>
</body>
</html>
